

import React, { Component } from 'react';
import Son from  "./Son";


export default class index extends Component {
  state={
    weight:120,
    count:2
  }

  changeWeight=()=>{
    this.setState({
      weight:this.state.weight+10
      
    })
  }


  changeCount=()=>{
    this.setState({
      count:this.state.count+1
    })
  }

  render() {

    const {weight,count} = this.state;
    return (
      <div>
        <h1>性能优化【react组件更新的性能优化】</h1>
        <p>count:{count}</p>
        <input type="button" value="修改count" onClick={this.changeCount} />

        <p>体重：{weight}</p>
        <input type="button" value="修改体重" onClick={this.changeWeight} />
        
        <Son weight={weight} />

      </div>
    )
  }
}
